package com.huizhonglm.diap.ui;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;

import com.bruce.common.utils.KeyboardUtil;
import com.huizhonglm.diap.R;
import com.huizhonglm.diap.core.utils.ProUtil;

/**
 * 描述当前类的作用
 *
 * @author LiXiaoLong
 * @version 1.0
 * @since 2016-03-01 17:39
 */
public abstract class BaseActivity extends FragmentActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    protected void setBackEvent(Activity childActivity, View.OnClickListener event){
        View backBtn = childActivity.findViewById(R.id.title_back_ibtn);
        if (event != null) {
            if (backBtn != null) {
                backBtn.setOnClickListener(event);
            }
        } else {
            if (backBtn != null) {
                backBtn.setOnClickListener(new View.OnClickListener(){
                    @Override
                    public void onClick(View v) {
                        finish();
                    }
                });
            }
        }
    }

    protected abstract void assignViews();


    protected void showProgressBar(){
        ProUtil.onCreate().show(BaseActivity.this);
    }

    protected void hideProgressBar(){
        ProUtil.onCreate().hide();
    }

    /**
     * 关闭软键盘
     */
    protected void closeKeyboard(Activity acti) {
        if (KeyboardUtil.isShowing(acti)) {
            KeyboardUtil.hideKeyboard(acti);
        }
    }
}
